package com.zhu.ssm.config;

import com.zhu.ssm.handler.MyInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
//开启mvc注解支持
//<mvc:annotation-driven />
@EnableWebMvc
@ComponentScan("com.zhu.ssm.controller")
public class SpringMvcConfig  implements WebMvcConfigurer {
    //配置拦截器
   @Autowired
   private MyInterceptor myInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(myInterceptor).addPathPatterns("/user/**")
                .excludePathPatterns("/user/test");
    }
}
